﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using db;

namespace DMSMT.MaterialMgr
{
    public partial class SaleOrderFrm : Form
    {
        public SaleOrderFrm()
        {
            InitializeComponent();
        }

        private void btSearchSO_Click(object sender, EventArgs e)
        {
            string socode =  tbSOCode.Text.Trim();
            string ddcode = tbDDCode.Text.Trim();
            string netcode = tbNetCode.Text.Trim();
            if (string.IsNullOrEmpty(socode + netcode))
            {
                MessageBox.Show("销售订单号和网点CODE不能全部为空!");
                return;
            }
            string sql = "select  sa.refer_code,sa.bill_code,sa.* from tt_pt_sale_order sa where 1=1 ";

            if (!string.IsNullOrEmpty(socode))
            {
                sql += " and sa.bill_code  like '%" + socode + "%'";
            }
            if (!string.IsNullOrEmpty(netcode))
            {
                sql += " and net_code =" + netcode;
            }
            if (!string.IsNullOrEmpty(ddcode))
            {
                sql += " or sa.refer_code like '%" + ddcode + "%'"; 
            }
            dgDatas.DataSource = Dao.searchDS("zj", sql).Tables[0];
        }
    }
}
